package www.yingdi365.com.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.TextView;

import www.yingdi365.com.R;
import www.yingdi365.com.base.ZjbBaseNotLeftActivity;
import www.yingdi365.com.fragment.HeKaFragment;

public class HeKaActivity extends ZjbBaseNotLeftActivity implements View.OnClickListener  {
    private TextView textViewRight;
    private TabLayout tablayout;
    private ViewPager viewPager;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_he_ka);
        init();
    }
    @Override
    protected void initSP() {

    }

    @Override
    protected void initIntent() {

    }

    @Override
    protected void findID() {
        textViewRight = (TextView) findViewById(R.id.textViewRight);
        tablayout = (TabLayout) findViewById(R.id.tablayout);
        viewPager = (ViewPager) findViewById(R.id.viewPager);
    }

    @Override
    protected void initViews() {
        ((TextView) findViewById(R.id.textViewTitle)).setText("贺卡");
        textViewRight.setText("我的贺卡");
        viewPager.setAdapter(new MyViewPagerAdapter(getSupportFragmentManager()));
        tablayout.setupWithViewPager(viewPager);
        tablayout.getTabAt(0).setText("节日");
        tablayout.getTabAt(1).setText("生日");
        tablayout.getTabAt(2).setText("婚礼");
    }

    @Override
    protected void setListeners() {
        findViewById(R.id.imageBack).setOnClickListener(this);
        textViewRight.setOnClickListener(this);
    }

    @Override
    protected void initData() {

    }

    @Override
    public void onClick(View v) {
        Intent intent = new Intent();
        switch (v.getId()) {
            case R.id.textViewRight:
                intent.setClass(this,WoDeHKActivity.class);
                startActivity(intent);
                break;
            case R.id.imageBack:
                finish();
                break;
        }
    }

    class MyViewPagerAdapter extends FragmentPagerAdapter {

        public MyViewPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {
            switch (position) {
                case 0:
                    return new HeKaFragment("festival");
                case 1:
                    return new HeKaFragment("birthday");
                case 2:
                    return new HeKaFragment("wedding");
                default:
                    return new HeKaFragment("festival");
            }
        }

        @Override
        public int getCount() {
            return 3;
        }
    }
}
